package com.wowangz.cms.common.utils;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

import com.wowangz.cms.common.pojo.DataDictionaryInfo;
import com.wowangz.cms.common.pojo.SysDataDictionary;
import com.wowangz.cms.common.pojo.SysDataDictionaryValue;
import com.wowangz.cms.common.service.SysDataDictionaryService;
import com.wowangz.cms.syscore.InitEnvironment;
import com.wowangz.cms.syscore.IssTransactionContainer;
import com.wowangz.cms.syscore.exception.ServiceException;
import com.wowangz.cms.syscore.pojo.BaseEntity;
import com.wowangz.cms.syscore.utils.SpringUtil;

/**
 * 
 * 获取缓存中的map
 * 
 * @author kaixia
 *
 */
public class DataCacheMapManage {
	
	private static final Logger logger = LoggerFactory.getLogger(DataCacheMapManage.class);
	
	
	
	public final static String getDataCacheMapObjectName(String mapkey,String fieldvaule,Class cls,String methodName) throws Exception
	{
		
		Map<String,List<Object>> map = InitEnvironment.getBaseDataCacheMap();
		
		List<Object> list = map.get(mapkey);
		
		BaseEntity returnBaseEntity = null;
		if(list != null)
		{
			for(int i=0; i<list.size(); i++)
			{
				BaseEntity baseEntity =(BaseEntity)list.get(i);
				if(Long.valueOf(fieldvaule).longValue() == baseEntity.getId().longValue())
				{
					returnBaseEntity = baseEntity;
					break;
				}
			}
		}
		if(returnBaseEntity == null)
		{
			return "";
		}
		Method operateMethod =  cls.getMethod(methodName, null);
		return operateMethod.invoke(returnBaseEntity).toString();
	}
	
	public static void main(String[] args) 
	{
		try 
		{
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
}
